def nearest_number(list_of_number: list, num: int)-> int:
    min_element = abs(list_of_number[0] - num)
    search_element = list_of_number[0]
    for element in list_of_number:
        temp = abs(element - num)
        if temp <= min_element:
            min_element = temp
            search_element = element
    return search_element

assert nearest_number([1,2,3,4,5,6,7,8,9], 5) == 5
assert nearest_number([10,20,30,40,50], 20) == 20
assert nearest_number([-1,-5,-10,-99], -50) == -10